<?php  
require_once('../system/common.inc.php');
base_url();
$rewrite_mod = get_option('rewrite_mod');
switch($rewrite_mod){
	case 3:
		$rewrite_url = array('view' => 'view/%d', 'view_nohistory' => 'view/%d/nohistory', 'screenshot' => 'screenshot/%d', 'history' => 'history/%d', 'contact' => 'contact/%d', 'section' => 'section/%d', 'report' => 'report/%d', 'report_support' => 'report/%1$d/%2$d', 'more' => 'more/%d', 'more_offset' => 'more/%1$d/%2$d', 'misc' => 'misc');
		break;
	case 1:
	case 2:
	default:
		$rewrite_url = array('view' => 'index.php?method=view&amp;pid=%d', 'view_nohistory' => 'index.php?pid=%d&amp;addr=nohistory', 'screenshot' => 'index.php?method=screenshot&amp;pid=%d', 'history' => 'index.php?method=history&amp;pid=%d', 'contact' => 'index.php?method=contact&amp;pid=%d', 'section' => 'index.php?method=section&amp;pid=%d', 'report' => 'index.php?method=report&amp;pid=%d', 'report_support' => 'index.php?method=report&amp;pid=%1$d&amp;support=%2$d', 'more' => 'index.php?method=more&amp;pid=%d', 'more_offset' => 'index.php?method=more&amp;pid=%1$d&amp;offset=%2$d', 'misc' => 'misc.php');
		break;
}
function echo_rewrite_url($type, $variable1, $variable2=''){
	global $rewrite_url;
	echo SITE_URL;
	printf($rewrite_url[$type], $variable1, $variable2);
}
class_loader('Mobile_Detect');
$detect = new Mobile_Detect;
if(!$detect->isiOS()){
	if (DCRM_PCINDEX == 2) {
		header("Location: ".SITE_URL.$rewrite_url['misc.php']);
		exit();
	} else {
		$isCydia = false;
	}
} else {
	if (DCRM_MOBILE == 2) {
		if (!strpos($detect->getUserAgent(), 'Cydia')) {
			$isCydia = false;
		} else {
			$isCydia = true;
		}
	} else {
		exit('Access Denied');
	}
}
if (file_exists('Release')) {
	$release = file('Release');
	$release_origin = __('No Name');
	$release_mtime = filemtime('Release');
	$release_time = date('Y-m-d H:i:s',$release_mtime);
	foreach ($release as $line) {
		if(preg_match('#^Origin#', $line)) {
			$release_origin = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
		if(preg_match("#^Description#", $line)) {
			$release_description = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
	}
} else {
	$release_origin = __('Cydia常见错误与解决办法');
}
if (isset($_GET['pid'])) {
	if (ctype_digit($_GET['pid']) && intval($_GET['pid']) <= 10000) {
		function device_check(){
			global $detect;
			$device_type = array('iPhone', 'iPod', 'iPad');
			for ($i = 0; $i < count($device_type); $i++) {
				$check = $detect->version($device_type[$i]);
				if ($check !== false) {
					if (isset($_SERVER['HTTP_X_MACHINE'])) {
						$DEVICE = $_SERVER['HTTP_X_MACHINE'];
					} else {
						$DEVICE = 'Unknown';
					}
					$OS = str_replace('_', '.', $check);
					break;
				}
			}
			return array('DEVICE' => $DEVICE, 'OS' => $OS);
		}

		if (isset($_GET['method']) && $_GET['method'] == 'screenshot') {
			$index = 2;
			$title = __('View Screenshots');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'report') {
			$device_info = device_check();
			if (!isset($_GET['support'])) {
				$index = 3;
			} else {
				if ($_GET['support'] == '1') {
					$support = 1;
				} elseif ($_GET['support'] == '2') {
					$support = 2;
				} elseif ($_GET['support'] == '3') {
					$support = 3;
				} else {
					$support = 0;
				}
				$index = 4;
			}
			$title = __('Report Problems');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'history') {
			$index = 5;
			$title = __('Version History');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'contact') {
			$index = 6;
			$title = __('Contact us');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'section') {
			$index = 7;
			$title = __('Package Category');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'more') {
			$index = 8;
			$section = DB::fetch_first("SELECT `Name`, `Icon` FROM `".DCRM_CON_PREFIX."Sections` WHERE `ID` = '".(int)$_GET['pid']."'");
			$q_name = DB::real_escape_string($section['Name']);
			if (isset($_GET['offset']) && !empty($_GET['offset']) && ctype_digit($_GET['offset'])) {
				$offset = intval($_GET['offset']);
			} else {
				$offset = 0;
			}
			$packages = DB::fetch_all("SELECT `ID`, `Name`, `Package` FROM `".DCRM_CON_PREFIX."Packages` WHERE (`Stat` = '1' AND `Section` = '".$q_name."') ORDER BY `ID` DESC LIMIT 10 OFFSET ".$offset);
			foreach($packages as $package){
				if(!empty($package)){
					if ($isCydia) { ?>
				<a href="cydia://package/<?php echo($package['Package']); ?>" target="_blank">
<?php					} else { ?>
				<a href="<?php echo_rewrite_url('view', $package['ID']);?>">
<?php					} ?>
					<img class="icon" src="<?php echo(SITE_URL); ?>icon/<?php echo(empty($section['Icon']) ? 'default/unknown.png' : $section['Icon']); ?>">
					<div>
						<div>
							<label>
								<p><?php echo($package['Name']); ?></p>
							</label>
						</div>
					</div>
				</a>
<?php
				}
			}
			exit();
		} elseif (!isset($_GET['method']) || (isset($_GET['method']) && $_GET['method'] == 'view')) {
			$index = 1;
			$title = __('View Package');
			$package_id = (int)DB::real_escape_string($_GET['pid']);
			$package_info = DB::fetch_first("SELECT `Name`, `Version`, `Author`, `Package`, `Description`, `DownloadTimes`, `Multi`, `CreateStamp`, `Size`, `Installed-Size`, `Section`, `Homepage`, `Tag`, `Level`, `Price`, `Purchase_Link`, `Changelog`, `Changelog_Older_Shows`, `Video_Preview`, `System_Support`, `ScreenShots` FROM `".DCRM_CON_PREFIX."Packages` WHERE `ID` = '".$package_id."' LIMIT 1");
			if ($package_info) $title = $title.' - '.$package_info['Name'];
		} else {
			httpinfo(405);
			exit();
		}
	} else {
		httpinfo(405);
		exit();
	}
} elseif (!isset($_GET['method'])) {
	$index = 0;
	$title = $release_origin;
} else {
	httpinfo(405);
	exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title><?php echo($title); ?></title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="apple-mobile-web-app-title" content="<?php echo($release_origin); ?>" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="HandheldFriendly" content="true" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="robots" content="index, follow" />
<?php
if (defined("AUTOFILL_SEO")) {
?>
		<meta name="title" content="<?php echo(AUTOFILL_SEO); ?>" />
<?php
}
if (!empty($release_description)) {
?>
		<meta name="description" content="<?php echo($release_description); ?>" />
<?php
}
if (defined("AUTOFILL_KEYWORDS")) {
?>
		<meta name ="keywords" content="<?php echo(AUTOFILL_KEYWORDS); ?>" />
<?php
}
if ($isCydia) {
?>
		<base target="_blank">
<?php
} else {
?>
		<base target="_top">
<?php
}
?>
		<link rel="apple-touch-icon" href="<?php echo(SITE_URL); ?>../CydiaIcon.png">
		<link rel="shortcut icon" href="<?php echo(SITE_URL); ?>../favicon.ico">
		<link type="text/css" media="screen" rel="stylesheet" href="./help/help.css">
	</head>
	<body class="pinstripe">
		<panel>
<?php
?>



<body class="pinstripe">
<panel>

<fieldset style="font-size:15px;"> 
    <div>
    <p><strong>错误一</strong></p>
    <hr>
    <ul>
      <li><em style="color:#F00"> i wasn't able to locate file for the <strong>com.active</strong>package. this might mean you need to manually fix this package  </em></li>
    </ul><p><strong>上方错误引起的原因</strong>：您打开Cydia在刷新的时候就去安装软件。
    </p><p><strong>解决办法：</strong>重启Cydia（关闭打开）然后马上关闭Cydia的刷新，或者等待刷新完。我们强烈建议您每次打开都等Cydia刷新完</p>
    </div>
</fieldset>
<fieldset style="font-size:15px;"> 
    <div>
    <p><strong>错误二</strong></p>
    <hr>
    <p><img src="./help/error2.png" alt="错误" width="270" height="56">
    </p><p>上方错误的原因是重复安装了不同标识一样的软件（在这拿FolderEnhancer举例）无法覆盖引起的
    </p><ul>
      <li><strong>为什么会有这种错误：</strong></li><p>每个源软件标识都会加入自己独特的字符（比如com.appcydia），这样既可以防止跟其它源相同软件冲突（被覆盖）又便于管理，但是相同的软件不同的标识安装前一个不卸载的前提下，再去安装另外源的一个会引起冲突，提示如上图所示。
      </p><li></li><p>1、Cydia1.1X版本以上会自动为您阻止这种情况发生，您无需担心。</p>
    </ul>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
    <p><strong>错误三</strong></p>
    <hr>
    <p><img src="./help/error3.jpg" alt="错误" width="270" height="405">
</p><ul>
    <p>上方错误说明您在重复尝试安装一个未购买的正版软件
</p>
<li>解决办法：如果您已购买，请在cydia登陆您购买该软件的账号后再试</li>
    </ul>
    </div>
</fieldset>


<fieldset style="font-size:15px;"> 
    <div>
    <p><strong>错误四</strong></p>
    <hr>
    <p><img src="./help/nopag.png" alt="错误" width="270" height="470">
</p><ul>
    <p>上方错误说明您现有源数据库中没有以该标识命名的软件
</p>
<li>解决办法：请确认包含该软件的软件源已添加</li>
    </ul>
    </div>
</fieldset>
<fieldset style="font-size:15px;"> 
    <div>
    <p><strong>错误五</strong></p>
    <hr>
    <ul>
      <li><em style="color:#F00">安装软件的时候提示“HTTP 404”</em></li>
<p>404说明当前软件下载地址找不到软件
</p><li><p><strong>解决办法：</strong>刷新一次cydia源如果还是无法解决，请联系源管理维护人员</p></li>
    </ul>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
    <p><strong>错误六</strong></p>
    <hr>
    <ul>
      <li><em style="color:#F00">安装软件的时候提示“Size mismatch”</em></li>
<p>Size mismatch一般是源软件的问题包不匹配等
</p><li><p><strong>解决办法：</strong>该情况一般不会发生，如果发生了在您彻底刷新一次源后还没解决的话，请联系源管理维护人员</p></li>
    </ul>
    </div>
</fieldset>

<fieldset style="font-size:15px;"> 
    <div>
    <p><strong>错误七</strong></p>
    <hr>
    <ul>
      <li><em style="color:#F00">安装软件的时候提示“Hash Sum mismatch”</em></li>
<li><p><strong>解决办法：</strong>重新刷新源清理缓存再试，如果还有问题请联系源管理维护人员</p></li>
    </ul>
    </div>
</fieldset>

<label><?php echo(AUTOFILL_SEO); ?></label>

<fieldset style="font-size:15px;"> 
    <a href="../index.php">
		<img class="icon" src="../CydiaIcon.png"><div>
        <label><?php echo(AUTOFILL_SEO); ?></label>
	</div></a>
    <div><p>如果您使用iOS Safari可以浏览以上两个地址来查看、收藏软件到您的源</p></div>
</fieldset>
<fieldset style="font-size:15px;"> 
    <div>
      <p><strong><em>问：</em></strong>提示“不支持您的系统，请勿安装”的我能安装吗？</p>
    <hr>
    <p>我们推出了这个功能，就是这个自动获取您当前使用机器的型号、固件来判断您安装的软件包是否兼容您的系统</p>
    <p>这个提示根据它下方的“设备兼容” 与 “系统兼容” 来自动判断，如下图</p>
    <p><img src="./help/ok.png" width="280" height="50"></p>
    <p><img src="./help/no.png" width="280" height="50"></p>
    <p>上传的deb我们至少会经过一台iOS设备测试，所以提示兼容的您可放心安装</p>
    <p>提示不兼容得，不建议您安装</p>
    </div>
</fieldset>

            <footer id="footer">
                <p>
                    <span class="source-name"><a href="../index.php" style="color: #6d6d72;"><?php echo(AUTOFILL_SEO); ?></a></span> ·
                    <span id="section">常见问题</span>
                </p>
            </footer> 
</panel>    